﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace JS
{
    public partial class _Default : System.Web.UI.Page
    {
        private string FilterRepeaterString(string s)
        {
            ArrayList reapeaterAL = new ArrayList();
            List<string> filterAL = new List<string>();
            string[] aryS = s.Split(' ');

            foreach (string sA in aryS)
            {
                //var query = from item in aryS
                //            where item.StartsWith(sA.Split(':')[0])
                //            select item;
                //var queryF = from itemF in filterAL
                //             where itemF.StartsWith(sA.Split(':')[0])
                //             select itemF;
                var query = aryS.Where(item => item.StartsWith(sA.Split(':')[0]));
                var queryF = filterAL.Where(item => item.StartsWith(sA.Split(':')[0]));
                if (query.Count() > 0 && queryF.Count() == 0)
                {
                    filterAL.Add(query.ElementAt(query.Count() -1));
                }
            }


            return string.Join(" ", filterAL.ToArray());
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            //Response.Write(this.FilterRepeaterString("A1:11 A2:22 A3:33 A1:45 A1:56 A2:47"));
            this.tbTestChange.Attributes.Add("onchange", "alert(this.value);");
            List<Person> person = new List<Person>
            {
               new Person{Name="Zhangsan",Scroes =new List<int> {10,23,43}},
               new Person{Name ="Lishi",Scroes =new List<int> {233,453,21}},
               new Person {Name ="Wangwu",Scroes =new List<int> {33,42,87}},
               new Person{Name ="Zhaoliu",Scroes =new List<int> {90,76,56}}
            };

            var testQuery = from per in person
                            from scr in per.Scroes
                            where scr > 50
                            group per by per.Name;
                            //select new {n=

            foreach (var test in testQuery)
            {
                //Response.Write(test.Key );
                foreach (var test1 in test)
                {
                    foreach (var scr in test1.Scroes)
                    {
                        //Response.Write(scr);
                    }
                        //Response.Write("<br />");
                }
            }

            var a = new { firstname = "zl", lastname = "zl" };

        }
    }

    public class Person
    {
        public string Name { get; set; }
        public List<int> Scroes { get; set; }
    }
}
